package com.erp.controller.productunit;

import com.erp.common.annotation.Anonymous;
import com.erp.common.core.controller.BaseController;
import com.erp.common.core.domain.AjaxResult;
import com.erp.common.core.page.TableDataInfo;
import com.erp.domain.ErpProductUnit;
import com.erp.service.productunit.IProduceunitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author cuicui
 * @Description
 * @Date 2025-9-3
 */
@RestController
@RequestMapping("/erp/product/unit")
public class ProduceunitController extends BaseController {
    @Autowired
    private IProduceunitService produceunitService;
    @GetMapping("/list")
    @Anonymous
    public TableDataInfo ListProduceunit(ErpProductUnit erpProductUnit, @RequestParam Map<String, Object> params) {

        erpProductUnit.getParams().putAll(params);
        startPage();
        List<ErpProductUnit> list = produceunitService.ListProduceunit(erpProductUnit);
        System.out.println("这是打印信息" + list);
        return getDataTable(list);
    }
    /**
     * 获取单位信息详细信息
     */
    @GetMapping("/getInfo/{unitId}")
    public AjaxResult getInfo(@PathVariable("unitId") Long unitId) {
        ErpProductUnit erpProductUnit = produceunitService.getInfo(unitId);
        return success(erpProductUnit);
    }
    /**
     * 新增单位信息
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ErpProductUnit erpProductUnit) {
        return toAjax(produceunitService.add(erpProductUnit));
    }
    /**
     * 修改单位信息
     */
    @PutMapping("/update")
    public AjaxResult update(@RequestBody ErpProductUnit erpProductUnit) {
        return toAjax(produceunitService.updateProductUnit(erpProductUnit));
    }

}
